const mysql = require("mysql2");

const connectionPool = mysql.createPool({
  host: "localhost",
  port: 3306,
  database: "node_mysql2",
  user: "root",
  password: "root",
  connectionLimit: 5, // 连接池中连接的个数
});

const statement = "select * from `products` where price > ? and score > ?";

connectionPool
  .promise() // 返回一个Promise对象
  .execute(statement, [100, 4.5])
  .then((result) => {
    const [values, fields] = result;
    console.log("-------------------values------------------");
    console.log(values);
    console.log("-------------------fields------------------");
    console.log(fields);
  })
  .catch((err) => {
    console.log(err);
  });
